package com.jingjiu.homeservicesbiz.controller;

import java.util.List;

import com.jingjiu.homeservicesapi.domain.DiseaseCategory;
import com.jingjiu.homeservicesbiz.service.IDiseaseCategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 疾病分类：用于管理疾病的分类信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/system/category")
public class DiseaseCategoryController extends BaseController
{

    @Autowired
    private IDiseaseCategoryService diseaseCategoryService;


    /**
     * 查询疾病分类：用于管理疾病的分类信息列表
     */
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(DiseaseCategory diseaseCategory)
    {
        startPage();
        List<DiseaseCategory> list = diseaseCategoryService.selectDiseaseCategoryList(diseaseCategory);
        return getDataTable(list);
    }

    /**
     * 导出疾病分类：用于管理疾病的分类信息列表
     */
    @Log(title = "疾病分类：用于管理疾病的分类信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody DiseaseCategory diseaseCategory)
    {
        List<DiseaseCategory> list = diseaseCategoryService.selectDiseaseCategoryList(diseaseCategory);
        ExcelUtil<DiseaseCategory> util = new ExcelUtil<DiseaseCategory>(DiseaseCategory.class);
        return util.exportExcel(list, "疾病分类：用于管理疾病的分类信息数据");
    }


    /**
     * 新增保存疾病分类：用于管理疾病的分类信息
     */
    @Log(title = "疾病分类：用于管理疾病的分类信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody DiseaseCategory diseaseCategory)
    {
        return toAjax(diseaseCategoryService.insertDiseaseCategory(diseaseCategory));
    }

    /**
     * 按id获取
     *
     * @param id   本我
     * @param mmap 内存映射
     * @return {@link DiseaseCategory }
     */
    @GetMapping("/get/{id}")
    public DiseaseCategory getById(@PathVariable("id") Long id)
    {
        DiseaseCategory diseaseCategory = diseaseCategoryService.selectDiseaseCategoryById(id);
       return diseaseCategory;
    }

    /**
     * 修改保存疾病分类：用于管理疾病的分类信息
     *
     * @param diseaseCategory 疾病类别
     * @return {@link AjaxResult }
     */
    @Log(title = "疾病分类：用于管理疾病的分类信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody DiseaseCategory diseaseCategory)
    {
        return toAjax(diseaseCategoryService.updateDiseaseCategory(diseaseCategory));
    }

    /**
     * 删除疾病分类：用于管理疾病的分类信息
     *
     * @param ids 入侵检测系统
     * @return {@link AjaxResult }
     */
    @Log(title = "疾病分类：用于管理疾病的分类信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(diseaseCategoryService.deleteDiseaseCategoryByIds(ids));
    }
}
